package net.xdclass.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import net.xdclass.model.AddressDO;
import net.xdclass.mapper.AddressMapper;
import net.xdclass.service.AddressService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 电商-公司收发货地址表 服务实现类
 * </p>
 *
 * @author zhaolei
 * @since 2025-10-10
 */
@Service
public class AddressServiceImpl extends ServiceImpl<AddressMapper, AddressDO> implements AddressService {

    @Autowired
    private AddressMapper addressMapper;

    @Override
    public AddressDO detail(Long id) {
        return addressMapper.selectById(id);
    }

    @Override
    public List<AddressDO> listAll() {
        //QueryWrapper本质上就是构造了一个查询的过滤条件
        QueryWrapper<AddressDO> queryWrapper = new QueryWrapper<>();
        return list(queryWrapper.orderByDesc("id"));
    }
}
